package demo06234;

    public class AlipayPayment implements Payment {
        private double balance;
        private String account;

        public AlipayPayment(double balance, String account) {
            this.balance = balance;
            this.account = account;
        }

        @Override
        public boolean pay(double amount) {
            if (balance >= amount) {
                balance -= amount;
                System.out.printf("支付宝(%s)支付成功: %.2f元\n", account, amount);
                return true;
            } else {
                System.out.println("支付宝余额不足，支付失败");
                return false;
            }
        }

        @Override
        public double getBalance() {
            return balance;
        }

        @Override
        public String getPaymentName() {
            return "支付宝支付";
        }
    }


